import static java.lang.Math.*;

public class DroneLine {
    public static void main(String[] args) {
        //区域半径/米
        int areaRadius = 1000;
        //侦察半径/米
        int reconnoiterRadius = 50;

        double[] startPoint = {112.994, 28.225};
        double[] targetPoint = {112.994, 29.225};

        //两点距离
        double distance = distance(startPoint[0], startPoint[1], targetPoint[0], targetPoint[1]);
        System.out.println(distance);

    }



    public static double distance(double lat1, double lon1, double lat2, double lon2) {
        // 地球半径，单位：千米
        double R = 6371.0;

        // 将经纬度转换为弧度
        double latDistance = toRadians(lat2 - lat1);
        double lonDistance = toRadians(lon2 - lon1);
        double a = sin(latDistance / 2) * sin(latDistance / 2)
                + cos(toRadians(lat1)) * cos(toRadians(lat2))
                * sin(lonDistance / 2) * sin(lonDistance / 2);
        double c = 2 * atan2(sqrt(a), sqrt(1 - a));
        double distance = R * c;

        return distance;
    }

}
